﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
using NetworkSupervisor.Model.NetworkSupervisor;

namespace NetworkSupervisor
{
    public partial class FormImportantSite : DevExpress.XtraEditors.XtraForm
    {
        public FormImportantSite()
        {
            InitializeComponent();
        }

        private void dataNavigator3_ButtonClick(object sender, NavigatorButtonClickEventArgs e)
        {
            switch (e.Button.ButtonType)
            {
                case NavigatorButtonType.Custom:
                    break;
                case NavigatorButtonType.First:
                    break;
                case NavigatorButtonType.PrevPage:
                    break;
                case NavigatorButtonType.Prev:
                    break;
                case NavigatorButtonType.Next:
                    break;
                case NavigatorButtonType.NextPage:
                    break;
                case NavigatorButtonType.Last:
                    break;
                case NavigatorButtonType.Append:
                    {
                        e.Handled = true;
                        ta重点对象 item = new ta重点对象(session1);
                        item.类别 = "网站";
                        item.Save();
                        XPC重点对象.Add(item);
                    }
                    break;
                case NavigatorButtonType.Remove:
                    {
                        e.Handled = true;
                        if (XPC重点对象.Count < 1) return;
                        if (XtraMessageBox.Show("是否确认删除", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                            (gridView3.GetFocusedRow() as ta重点对象).Delete();
                    }
                    break;
                case NavigatorButtonType.Edit:
                    break;
                case NavigatorButtonType.EndEdit:
                    {
                        XtraMessageBox.Show("保存成功");
                    }
                    break;
                case NavigatorButtonType.CancelEdit:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }

        private void gridControl3_DoubleClick(object sender, EventArgs e)
        {
            if (XPC重点对象.Count < 1) return;

            ta重点对象 item = gridView3.GetFocusedRow() as ta重点对象;
            if (item.网址 == "") return;
            item.上次检查时间 = DateTime.Now;
            item.Save();
            System.Diagnostics.Process.Start(item.网址);
        }

        private void gridView3_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator)
                e.Info.DisplayText = "双击此处打开网址。" + (e.RowHandle + 1).ToString();
        }
    }
}